//
//  NSArray+SortArray.m
//  xiaohu
//
//  Created by 刘璇 on 2017/11/10.
//  Copyright © 2017年 iOSOneGpowerMobile. All rights reserved.
//

#import "NSArray+SortArray.h"

@implementation NSArray (SortArray)
/**
 升序
 
 */
+(NSMutableArray *)arraySortASCWithArray:(NSMutableArray *)array{
    NSLog(@"array!!!!%@",array);
    [array sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
        NSString *a = (NSString *)obj1;
        NSString *b = (NSString *)obj2;
        
        int aNum = [a intValue];
        int bNum = [b intValue];
        
        if (aNum > bNum) {
            return NSOrderedDescending;
        }
        else if (aNum < bNum){
            return NSOrderedAscending;
        }
        else {
            return NSOrderedSame;
        }
    }];
    return array;
}


/**
 降序
 */
+(NSArray *)arraySortDESCWithArray:(NSArray *)array{
    return [array sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {
        return [obj2 compare:obj1]; //降序
        
    }];
}
@end
